﻿Imports Microsoft.DirectX.Direct3D
Imports Microsoft.DirectX
Public Class ObjektLabel
    Inherits Objekt2D
    Public Text As ObjektText
    Public Sub New(ByVal X As Integer, ByVal Y As Integer, ByVal Bild As String, ByVal Text() As String, ByVal Textposition As Point, ByVal Schriftgröße As Integer, ByVal neuFrames As Integer, ByVal Fixed As PointF, Optional ByVal Handler As ObjektPanel = Nothing)
        MyBase.New(Bild, New Rectangle(X, Y, Image.FromFile(Bild).Width / (neuFrames + 1), Image.FromFile(Bild).Height), New Point(X, Y), Fixed, Handler)

        MaxeFrame = New Point(neuFrames, 0)
        Dim T(Text.Length - 1) As String
        For I = 0 To T.Length - 1
            T(I) = Sprachconverter.Translate(Text(I))
        Next
        Me.Text = New ObjektText(T, Textposition.X, Textposition.Y, Nothing, "Arial", Schriftgröße, FontStyle.Regular)
    End Sub

    Public Overrides Function Keydown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) As Boolean
        Return False
    End Function

    Public Overrides Function KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) As Boolean
        Return False
    End Function

    Public Overrides Function MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) As Boolean
        Return False
    End Function

    Public Overrides Function MouseEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) As Boolean
        Return False
    End Function

    Public Overrides Function MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) As String
        Return ""
    End Function
    Public Overrides Sub Malen()
        If Handler IsNot Nothing Then
            If Not Handler.IsVisible(New Rectangle(Koordinaten.X, Koordinaten.Y, Rechteck.Width, Rechteck.Height), True) Then
                Exit Sub
            End If
        End If
        Dim sngRotation As Double = 0
        Dim intColor As Color = Color.FromArgb(255, 255, 255, 255)
        With Grafikengine.recBild
            .X = Frame.X * Rechteck.Width : .Width = Rechteck.Width
            .Y = 0 : .Height = Rechteck.Height
        End With
        Grafikengine.ptfRotCenter = New Point(0, 0)
        Grafikengine.ptfPosition = GetRealKoordinaten()
        With Grafikengine.szfScale
            .Width = Rechteck.Width
            : .Height = Rechteck.Height
        End With
        Grafikengine.Sprite.Draw2D(Textur.getTextur(TexturID), Grafikengine.recBild, Grafikengine.szfScale, Grafikengine.ptfRotCenter, sngRotation, Grafikengine.ptfPosition, intColor)
        If IsNothing(Text) = False Then
            Text.Malen(Grafikengine.Sprite)
        End If
        Frame = New Point(Frame.X + 1, Frame.Y)
        If IsNothing(Text) = False Then
            Text.Malen(Grafikengine.Sprite)
        End If
    End Sub
    ''Public Rechteck As Rectangle
    ''Dim Text As ObjektText
    ''Dim Textur As Texture
    ''Dim FrameMax As Integer
    ''Private Frames As Integer
    ''Public Property Frame() As Integer
    ''    Get
    ''        Return Frames
    ''    End Get
    ''    Set(ByVal value As Integer)
    ''        Frames += 1
    ''        If FrameMax < Frames Then
    ''            Frames = 0
    ''        End If
    ''    End Set
    ''End Property
    ''Public Sub New(ByVal X As Integer, ByVal Y As Integer, ByVal Bild As String, ByVal T() As String, ByVal Textposition As Point, ByVal Schriftgröße As Integer, ByVal neuFrames As Integer)
    ''    FrameMax = neuFrames
    ''    Dim B As Image = Image.FromFile(My.Settings.Resourcenpfad + "Objekte\" + Bild + ".png")
    ''    Textur = Grafikengine.LoadTexture(B)
    ''    Rechteck = New Rectangle(X, Y, B.Width / (neuFrames + 1), B.Height)
    ''    Text = New ObjektText(T, Textposition.X, Textposition.Y, Nothing, "Arial", Schriftgröße, FontStyle.Regular)
    ''End Sub
    ''Public Sub Malen()
    ''    Dim sngRotation As Double = 0
    ''    Dim intColor As Color = Color.FromArgb(255, 255, 255, 255)
    ''    With Grafikengine.recBild
    ''        .X = Frames * Rechteck.Width : .Width = Rechteck.Width
    ''        .Y = 0 : .Height = Rechteck.Height
    ''    End With
    ''    Grafikengine.ptfRotCenter = New Point(0, 0)
    ''    Grafikengine.ptfPosition = New Drawing.Point(Rechteck.X, Rechteck.Y)
    ''    With Grafikengine.szfScale
    ''        .Width = Rechteck.Width
    ''        : .Height = Rechteck.Height
    ''    End With
    ''    Grafikengine.Sprite.Draw2D(Textur, Grafikengine.recBild, Grafikengine.szfScale, Grafikengine.ptfRotCenter, sngRotation, Grafikengine.ptfPosition, intColor)
    ''    If IsNothing(Text) = False Then
    ''        Text.Malen(Grafikengine.Sprite)
    ''    End If
    ''    Frame = 1
    ''End Sub

End Class
